<!--机构内部转账业务审核页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :labelWidth="80"
    >
      <template slot="endSlotOption">
        <amount-range-search label="交易金额" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('detials', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细弹出框 -->
    <details-dialog
      ref="detailsDialog"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></details-dialog>
  </div>
</template>
<script>
import { apiUrlConfig, detailsQuery } from "@/api/cnaps/baseBiz/interTransfer/inside_transfer_approve.js";
import DetailsDialog from "./components/InsideTransferApproveDetails";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";

export default {
  name: "InsideTransferApprove",
  mixins: [listPageMixin],
  components: {
    AmountRangeSearch,
    DetailsDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: ["TXN_SOURCE", "CBFLAG", "BANK_BIZ_TYPE"],
      //  明细弹框数据
      // form表单字段
      formData: {
        id: "",
        cpgDate: "",
        workdate: "",
        cbflag: "",
        source: "",
        bizTypeCode: "",
        payerAgency: "",
        payerBrname: "",
        payerAccBrno: "",
        payerAccBrname: "",
        payerActno: "",
        payerName: "",
        payerAddr: "",
        payeeActno: "",
        payeeName: "",
        payeeAddr: "",
        payeeAgency: "",
        payeeBrname: "",
        payeeAccBrno: "",
        payeeAccBrname: "",
        curcd: "",
        amount: "",
        remarks: "",
        mdTlrno: "",
        mdTime: "",
        audRemarks: "",
      },
      showSearch: true,
      // 查询参数
      queryParams: {
        idDate: "",
        id: "",
        cpgdate: "",
        cpgdate2: "",
        amount: "",
        amount2: "",
        source: "",
      },
      formOptions: [],
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "200", align: "center" },
        {
          label: `CPG日期`,
          prop: "cpgdate",
          width: "150",
          align: "center",
          type: "date",
        },
        {
          label: `业务类型`,
          prop: "bizTypeCode",
          width: "150",
          align: "center",
          dictCode: "BANK_BIZ_TYPE",
        },
        {
          label: `业务状态`,
          prop: "bizStatus",
          width: "140",
          align: "center",
          dictCode: "TXN_STATUS",
        },
        {
          label: `来源`,
          prop: "source",
          width: "140",
          align: "center",
          dictCode: "TXN_SOURCE",
        },
        {
          label: `复核操作员`,
          prop: "ckTlrno",
          width: "140",
          align: "center",
        },
        {
          label: `复核时间`,
          prop: "ckTime",
          align: "center",
          type: "date",
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "TXN_SOURCE",
        prop: "source",
        defaultAttr: {
          size: "small",
          label: "来源",
          placeholder: "请选择来源",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "detials":
          // 明细信息
          detailsQuery(row).then((res) => {
            this.formData = _.clone(res.result);
            this.$refs.detailsDialog.show();
          });
          break;
      }
    },
  },
};
</script>
